package com.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sys.dao.DepartmentDao;
import com.sys.entity.Department;
import com.sys.service.DepartmentService;
@Service
public class DepartmentServiceImpl implements DepartmentService {

	@Autowired
	private DepartmentDao DepartmentDao;
	@Override
	public Map<String, Object> getAllDepartment(Integer deptid, String deptname, String description, String createtime,
			String updatetime, Integer del, Integer page, Integer limit) {
		Map<String, Object> prams=new HashMap<String, Object>();
		prams.put("deptid", deptid);
		prams.put("deptname", deptname);
		prams.put("description", description);
		prams.put("createtime", createtime);
		prams.put("updatetime", updatetime);
		prams.put("del", del);
		page = (page - 1) * limit;
		prams.put("page", page);
		prams.put("limit", limit);
		List<Department> list=DepartmentDao.getAllDepartment(prams);
		int total=DepartmentDao.getAllDepartmentCount(prams);
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", total);
		return map;
	}

	@Override
	public int addDepartment(Department department) {
		int len=DepartmentDao.addDepartment(department);
		return len;
	}

	@Override
	public int updateDepartment(Department department) {
		int len=DepartmentDao.updateDepartment(department);
		return len;
	}

	@Override
	public int deleteDepartment(Department department) {
		int len=DepartmentDao.deleteDepartment(department);
		return len;
	}

}
